<template>
	<view class="consumption-page">
		<!-- 自定义导航栏 -->
		<view class="nav-bar" :style="{ paddingTop: statusBarHeight + 'px' }">
			<view class="nav-content">
				<view class="nav-back" @click="goBack">
					<text class="back-icon">‹</text>
				</view>
				<text class="nav-title">消费记录</text>
				<view class="nav-right">
					<text class="nav-icon">⋯</text>
					<text class="nav-icon">○</text>
				</view>
			</view>
		</view>

		<!-- 内容区域 -->
		<view class="content-area">
			<view 
				class="record-item" 
				v-for="(item, index) in recordList" 
				:key="index"
			>
				<view class="record-left">
					<text class="service-desc">{{ item.service }}</text>
					<text class="record-time">{{ item.time }}</text>
				</view>
				<view class="record-right">
					<text class="record-amount">{{ item.amount }}</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script setup>
	import {
		onLoad
	} from '@dcloudio/uni-app';
	import {
		ref
	} from 'vue';

	// 状态栏高度
	const statusBarHeight = ref(0);

	// 消费记录列表数据
	const recordList = ref([
		{
			service: '大美汽车维修店-洗车',
			time: '2023.3.11 11:09',
			amount: '-50元'
		},
		{
			service: '大美汽车维修店-洗车',
			time: '2023.3.11 11:09',
			amount: '-50元'
		},
		{
			service: '大美汽车维修店-洗车',
			time: '2023.3.11 11:09',
			amount: '-50元'
		},
		{
			service: '大美汽车维修店-洗车',
			time: '2023.3.11 11:09',
			amount: '-50元'
		}
	]);

	// 返回上一页
	const goBack = () => {
		uni.navigateBack();
	};

	onLoad(() => {
		// 获取状态栏高度
		const systemInfo = uni.getSystemInfoSync();
		statusBarHeight.value = systemInfo.statusBarHeight;
	});
</script>

<style scoped>
	.consumption-page {
		background-color: #f5f5f5;
		min-height: 100vh;
	}

	/* 导航栏 */
	.nav-bar {
		background-color: #007AFF;
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		z-index: 1000;
	}

	.nav-content {
		height: 44px;
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 0 30rpx;
	}

	.nav-back {
		width: 60rpx;
		height: 60rpx;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.back-icon {
		color: #fff;
		font-size: 48rpx;
		font-weight: 300;
		line-height: 1;
	}

	.nav-title {
		color: #fff;
		font-size: 36rpx;
		font-weight: 500;
		flex: 1;
		text-align: center;
	}

	.nav-right {
		display: flex;
		align-items: center;
		gap: 20rpx;
	}

	.nav-icon {
		color: #fff;
		font-size: 40rpx;
	}

	/* 内容区域 */
	.content-area {
		margin-top: calc(44px + var(--status-bar-height, 0px));
		background-color: #fff;
		padding: 0;
	}

	/* 消费记录条目 */
	.record-item {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 30rpx;
		border-bottom: 1px solid #f0f0f0;
		background-color: #fff;
		box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
		margin-bottom: 2rpx;
	}

	.record-left {
		flex: 1;
		display: flex;
		flex-direction: column;
		gap: 12rpx;
	}

	.service-desc {
		font-size: 32rpx;
		color: #333;
		font-weight: 500;
	}

	.record-time {
		font-size: 28rpx;
		color: #999;
	}

	.record-right {
		display: flex;
		align-items: center;
	}

	.record-amount {
		font-size: 32rpx;
		color: #333;
		font-weight: 500;
	}
</style>
